package com.study.dao;

import com.study.domain.Emp;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

public interface IEmpDao {
    @Select("select * from emp")
    @Results(id="empMap",value = {
            @Result(id = true,column = "empno",property = "empno"),
            @Result(column = "ename",property = "ename"),
            @Result(column = "hiredate",property = "hiredate"),
            @Result(column = "job",property = "job"),
            @Result(column = "sal",property = "sal"),
            @Result(column = "empno",property = "users",many = @Many(select = "com.study.dao.IUserDao.findByEmpno",fetchType = FetchType.LAZY))
    })
    public List<Emp> findAll();
    @Select("select * from emp where empno=#{empno}")
    public Emp findById(String empno);
}
